 package tools;

 import java.util.ArrayList;
 import java.util.List;

 public class BuffPacketTool {
/*   7 */   private static int 数据包长度 = 256;

   public static void main(String[] atgs) {
/*  10 */     String packet = "00 00 00 00 \n00 20 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 03 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 30 00 00 \n08 00 00 00 \n84 02 00 00 \n20 00 00 00 \n08 00 00 10 \n01 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 F8 07 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 \n00 00 00 00 ";
































/*  43 */     System.out.println(拆包(packet));
   }

   public static String 拆包(String 数据包) {
/*  47 */     String st = 数据包.replace(" ", "").trim();
/*  48 */     st = st.replace("\n", "").trim();
/*  49 */     if (st.length() < 数据包长度) {
/*  50 */       System.out.println("必须是19个mask组成的BUFFSTATS或不含包头的 含完整19个mask的包");
/*  51 */       return "";
/*  52 */     }  if (st.length() > 数据包长度) {
/*  53 */       System.out.println("包是过长的  尝试拆");
/*  54 */       st = st.substring(0, 数据包长度);
     }
/*  56 */     if (st.length() != 数据包长度) {
/*  57 */       return "";
     }
/*  59 */     String[] st2 = new String[数据包长度 / 2 / 4];
/*  60 */     StringBuilder value3 = new StringBuilder();
/*  61 */     for (int i2 = 0; i2 < 数据包长度 / 2 / 4; i2++) {
/*  62 */       st2[i2] = st.substring(i2 * 8, i2 * 8 + 8);
/*  63 */       char[] addressArray = st2[i2].toCharArray();
/*  64 */       StringBuilder sb = new StringBuilder();
/*  65 */       for (int i = addressArray.length - 1; i >= 0; i -= 2) {
/*  66 */         sb.append(addressArray[i - 1]);
/*  67 */         sb.append(addressArray[i]);
       }
/*  69 */       long hex = Long.valueOf(sb.toString(), 16).longValue();
/*  70 */       String binary = Long.toBinaryString(hex);


/*  73 */       List<Integer> position = new ArrayList<>();

/*  75 */       for (int j = 0; j < binary.length(); j++) {
/*  76 */         if (binary.toCharArray()[j] == '1') {
/*  77 */           position.add(Integer.valueOf(j));
         }
       }
/*  80 */       String content = binary + "\n";
/*  81 */       String value = "";
/*  82 */       String value2 = "";
/*  83 */       for (Integer integer : position) {
/*  84 */         value = "1";
/*  85 */         for (int k = 0; k < binary.length() - integer.intValue() - 1; k++) {
/*  86 */           value = value + "0";
         }
/*  88 */         value2 = Long.toHexString(Long.valueOf(value, 2).longValue());
/*  89 */         if (value2.isEmpty()) {
           continue;
         }
/*  92 */         long value4 = (i2 * 32);
/*  93 */         long buffstat = (1 << (int)(31L - value4 % 32L));
/*  94 */         if (buffstat > 2147483648L) {
/*  95 */           return "";
         }
/*  97 */         buffstat = Long.parseLong(value2, 16);
/*  98 */         int value5 = 0;
/*  99 */         while (buffstat > 1L) {
/* 100 */           buffstat /= 2L;
/* 101 */           value5++;
         }
/* 103 */         value5 = 31 - value5;
/* 104 */         value5 = (int)(value5 + value4);
/* 105 */         value3.append(String.valueOf(value5)).append("\n");
       }
     }

/* 109 */     return value3.toString();
   }
 }


/* Location:              C:\PGX\Server.jar!\tools\BuffPacketTool.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */